package socketVersion.Backend.Rooms;

import java.util.LinkedList;

import socketVersion.GenericClient;
import socketVersion.Reply;
import socketVersion.Request;

public class RoomServerWrapper extends GenericClient implements RoomInterface{

	public RoomServerWrapper(String ip, int port) {
		super(ip, port);
	}

	@Override
	public boolean addRooms(int id, String location, int numRooms, int price) {
		return false;
	}

	@Override
	public boolean deleteRooms(int id, String location) {
		return false;
	}

	@Override
	public int queryRooms(int id, String location) {
		return 0;
	}

	@Override
	public int queryRoomsPrice(int id, String location) {
		return 0;
	}

	@Override
	public boolean reserveRoom(int id, int customer, String location) {
		LinkedList<Object> args = new LinkedList<Object>();
		args.add(id);
		args.add(customer);
		args.add(location);
		
		Request request = new Request("reserveRoom",args);
		Reply reply = sendRequest(request);
		if(reply.getStatus()==Reply.STATUS_SUCCESS){
			return ((Boolean)reply.getOutput().get(0)).booleanValue();
		}
		else{
			return false;
		}
	}

	@Override
	public boolean deleteReservation(int id, int customer) {
		LinkedList<Object> args = new LinkedList<Object>();
		args.add(id);
		args.add(customer);
		
		Request request = new Request("deleteReservation",args);
		Reply reply = sendRequest(request);
		if(reply.getStatus()==Reply.STATUS_SUCCESS){
			return ((Boolean)reply.getOutput().get(0)).booleanValue();
		}
		else{
			return false;
		}
	}

	@Override
	public int calculateBill(int id, int customer) {
		LinkedList<Object> args = new LinkedList<Object>();
		args.add(id);
		args.add(customer);
		
		Request request = new Request("calculateBill",args);
		Reply reply = sendRequest(request);
		if(reply.getStatus()==Reply.STATUS_SUCCESS){
			return ((Integer)reply.getOutput().get(0)).intValue();
		}
		else{
			return -1;
		}
	}

}
